package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.saas.domain.dao.BatchFlowBillDao;
import com.xbongbong.saas.domain.dao.SettleAccountsDao;
import com.xbongbong.saas.domain.entity.SettleAccountsEntity;
import com.xbongbong.saas.model.SettleAccountsModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 结账model
 *
 * @author ruansicheng
 **/
@Service("settleAccountsModel")
public class SettleAccountsModelImpl implements SettleAccountsModel {

    @Resource
    private SettleAccountsDao settleAccountsDao;

    @Override
    public Integer insert(SettleAccountsEntity entity) throws XbbException {
        entity.setAddTime(DateTimeUtil.getInt());
        entity.setUpdateTime(DateTimeUtil.getInt());
        return settleAccountsDao.insert(entity);
    }

    @Override
    public Integer update(SettleAccountsEntity entity) throws XbbException {
        entity.setUpdateTime(DateTimeUtil.getInt());
        return settleAccountsDao.update(entity);
    }

    @Override
    public List<SettleAccountsEntity> findEntitys(Map<String, Object> param) {
        return settleAccountsDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return settleAccountsDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public SettleAccountsEntity getLastSettleAccounts(String corpid) {
        return settleAccountsDao.getLastSettleAccounts(corpid);
    }

    @Override
    public void cleanSettleAccounts(String corpid) {
        settleAccountsDao.cleanSettleAccounts(corpid);
    }
}
